package com.heo.matchmatebackend.once;

import com.heo.matchmatebackend.mapper.UserMapper;
import com.heo.matchmatebackend.model.domain.User;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

import javax.annotation.Resource;

@Component
public class InsertUsers {
    @Resource
    private UserMapper userMapper;

    /**
     * 循环插入用户
     */
//    @Scheduled(initialDelay = 5000,fixedRate = Long.MAX_VALUE )
    public void doInsertUser() {
        StopWatch stopWatch = new StopWatch();
        System.out.println("执行。。。");
        stopWatch.start();
        final int INSERT_NUM = 1000;
        for (int i = 0; i < INSERT_NUM; i++) {
            User user = new User();
            user.setUsername("假用户");
            user.setUserAccount("fakeUser");
            user.setAvatarUrl("https://ts1.cn.mm.bing.net/th/id/R-C.671703da4315919a5266b547694ba3d8?rik=iUxZAh3XI4he5A&riu=http%3a%2f%2fimg.touxiangkong.com%2fzb_users%2fupload%2f2022%2f12%2f202212111670748923309918.jpg&ehk=1BxDQaPkZu0f5FZCRtErWN9qBO3WpC%2f12wxm%2bYXSPzQ%3d&risl=&pid=ImgRaw&r=0");
            user.setProfile("一个假用户");
            user.setGender(0);
            user.setUserPassword("123456");
            user.setPhone("123456");
            user.setEmail("123456@qq.com");
            user.setUserStatus(0);
            user.setUserRole(0);
            user.setUserCode("100");
            user.setTags("[]");
            userMapper.insert(user);
        }
        stopWatch.stop();
        System.out.println(stopWatch.getLastTaskTimeMillis());

    }
}
